public class thre {
    public static void main(String[] args) {
        Object lock=new Object();
        Thread t1=new Thread(() -> {
            int i=0;
            for(i=0;i<5;i++)
            {
                ;

            }
            System.out.println("线程1已经执行完,去通知线程2执行");
            synchronized (lock) {
                lock.notify();
            }


        });
        Thread t2=new Thread(() ->{
            synchronized (lock) {
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程2已经执行完");

        });
        t1.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        t2.start();
    }
}
